package com.itheima.demo.demo03;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class sort {
    public static void main(String[] args) {
        ArrayList<Person>list=new ArrayList<>();
        Person p1=new Person("a张卫健",45);
        Person p2=new Person("c姜大卫",65);
        Person p3=new Person("b狄龙",65);
        list.add(p1);
        list.add(p2);
        list.add(p3);
        System.out.println(list);
        Collections.sort(list,(o1,o2)->{
            return o2.getAge()-o1.getAge();
                }
        );
        System.out.println(list);


    }
}
